﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yaip {
    public class ConvolutionMatrix {


        private int[,] matrix;

        private int factor = 1;
        private int offset = 0;
        private int radius;

        public int getFactor() { return factor; }
        public void setFactor(int factor) { this.factor = factor; }
        public int getOffset() { return offset; }
        public void setOffset(int offset) { this.offset = offset; }
        public int getRadius() { return radius; }
        public int getMatrixValue(int x, int y) { return matrix[x, y]; }


        /// <summary>
        /// Creates a Convolution Matrix for filter processing.
        /// </summary>
        /// <param name="radius">Convolution Matrix radius.</param>
        public ConvolutionMatrix(int radius) {
            if (radius == 2) {
                matrix = new int[5, 5] { 
                    { 0, 0, 0, 0, 0 }, 
                    { 0, 0, 0, 0, 0 }, 
                    { 0, 0, 0, 0, 0 }, 
                    { 0, 0, 0, 0, 0 }, 
                    { 0, 0, 0, 0, 0 } 
                };
                this.radius = 2;
            } else {
                matrix = new int[3, 3] { 
                    { 0, 0, 0 }, 
                    { 0, 0, 0 }, 
                    { 0, 0, 0 } 
                };
                this.radius = 1;
            }
        }

        public ConvolutionMatrix(int[,] matrix) {
            //TODO: make verifications!!!
            this.matrix = matrix;
        }



        /// <summary>
        /// Sets a given position of the matrix to a value.
        /// </summary>
        /// <param name="x">Line of the matrix.</param>
        /// <param name="y">Column of the matrix.</param>
        /// <param name="value">Value to set in the matrix.</param>
        public void setMatrixValue(int x, int y, int value) {
            //TODO: matrix size problems....throw exception!!!!
            matrix.SetValue(value, x, y);
        }


        /// <summary>
        /// Sets all the positions of the matrix with the same value.
        /// </summary>
        /// <param name="v">Value to set all positions.</param>
        public void setAllMatrix(int v) {

        }
    }
}
